﻿#include <stdio.h>
#include <thread>
#include <sstream>

#include "thpool.h"
#include "TinyLog.h"

int a1=0;
int a2=10;
int a3=20;
int a4=30;

void f(int a,int b)
{
	TDEBUG("value is : "<< a+b);
}

int main(int argc,char* argv[])
{
	n::thpool pool;
	pool.init(10);

	//向线程池添加任务
	std::function<void(void)> f1=std::bind(f,a1,a2);
	std::function<void(void)> f2=std::bind(f,a2,a3);
	std::function<void(void)> f3=std::bind(f,a3,a4);
	std::function<void(void)> f4=std::bind(f,a4,a1);

	for(int i=0;i<10;i++){
		pool.push_task(f1);
		pool.push_task(f2);
		pool.push_task(f3);
		pool.push_task(f4);
	}

	//TINFO("a1="<<a1<<",a2="<<a2<<",a3="<<a3<<",a4="<<a4);

	char a;
	std::cin >> a;
	return 0;
}
